$.extend(validatePrompt, {
	name : {
		onFocus : "2-20位字符，可由中文或英文组成",
		succeed : "",
		isNull : "请选择设备名称",
		error : {
			badLength : "设备名称长度只能在2-20位字符之间",
			badFormat : "设备名称只能由中文或英文组成"
		}
	},
	deviceTypeId : {
		onFocus : "请选择设备型号",
		succeed : "",
		isNull : "请选择设备型号",
		error : "请选择设备型号"
	},
	description : {
		onFocus : "2-20位字符，可由中文或英文组成",
		succeed : "",
		isNull : "请输入联系人姓名",
		error : ""
	}
});
$.extend(validateFunction,
		{
			name : function(option) {
				var length = validateRules.betweenLength(option.value.replace(
						/[^\x00-\xff]/g, "**"), 2, 20);
				var format = validateRules.isRealName(option.value);
				if (!length) {
					validateSettings.error.run(option,
							option.prompts.error.badLength);
				} else {
					if (!format) {
						validateSettings.error.run(option,
								option.prompts.error.badFormat);
					} else {
						validateSettings.succeed.run(option);
					}
				}
			},
			deviceTypeId : function(option) {
				var bool = (option.value == -1);
				if (bool) {
					validateSettings.isNull.run(option, "");
				} else {
					validateSettings.succeed.run(option);
				}
			},
			addDeviceModel_validate : function() {

				$("#name").jdValidate(validatePrompt.name,
						validateFunction.name, true);
				$("#deviceTypeId").jdValidate(validatePrompt.deviceTypeId,
						validateFunction.deviceTypeId, true);
				return validateFunction
						.FORM_submit([ "#name", "#deviceTypeId" ]);
			},
			updateDeviceModel_validate : function() {

				$("#name").jdValidate(validatePrompt.name,
						validateFunction.name, true);
				$("#deviceTypeId").jdValidate(validatePrompt.deviceTypeId,
						validateFunction.deviceTypeId, true);
				return validateFunction
						.FORM_submit([ "#name", "#deviceTypeId" ]);
			}
		});

$("#name").jdValidate(validatePrompt.name, validateFunction.name);
$("#deviceTypeId").jdValidate(validatePrompt.deviceTypeId,
		validateFunction.deviceTypeId);

$("#addDeviceModeSubmit").click(function() {

	var flag = validateFunction.addDeviceModel_validate();
	if (flag) {
		$("#addDeviceModel").submit();
	}
});
$("#updateDeviceModeSubmit").click(function() {
	var flag = validateFunction.updateDeviceModel_validate();
	if (flag) {
		$("#updateDeviceModel").submit();
	}
});